import service from '../utils/axios.js'

/**
 * TODOapi接口集合
 * @method getAll 获取全部待办项
 * @method addOne 添加一项
 * @method edit 修改一项
 * @method delById 根据id删除一项
 */
export default {
  getAll: () => {
    return service.get('/todos')
  },
  addOne: (data) => {
    return service.post('/todos', data)
  },
  // data:
  // {
  //   "content": "test"
  // }
  edit: (id, data) => {
    return service.put(`/todos/${id}`, data)
  },
  // data:
  // {
  //   "content": "test-new",
  //   "completed": 1
  // }
  delById: (id) => {
    return service.delete(`/todos/${id}`)
  },
}

// 用法
// import todosApi from '@/apis/todos.js'
// todosApi.getAll().then((res) => {})
